<?php 

class Events_model extends CI_Model {
    
    function __construct() {
        parent::__construct();
    }

    function getEventData() {
        $collection = $this->mongo_db->db->selectCollection('events');
        $events = $collection->find();      
        return $events;	
    }
    function getEventsArr($arr) {
        $collection = $this->mongo_db->db->selectCollection('events');
        $events = $collection->find(array("_id" => array('$in' => $arr)));      
        return $events; 
    }

    function getVnTime() {
        $collection = $this->mongo_db->db->selectCollection('events');
        $times = $collection->find(array('type'=> 'VN'), array('from' => true, 'to' => true));      
        return $times;
    }

    function getWorldTime() {
        $collection = $this->mongo_db->db->selectCollection('events');
        $times = $collection->find(array('type'=> 'WO'), array('from' => true, 'to' => true));      
        return $times;
    }

    function getProvinces($arr) {
        $collection = $this->mongo_db->db->selectCollection('coordinate');
        $provinces = $collection->find(array('_id' => array('$in' => $arr)));
        return $provinces;
    }

    function getCountries($arr) {
        $collection = $this->mongo_db->db->selectCollection('countries');
        $countries = $collection->find(array('_id' => array('$in' => $arr)));
        return $countries;
    }

    function getAllCountries() {
        $collection = $this->mongo_db->db->selectCollection('countries');
        $countries = $collection->find(array(), array("polygons" => 0));
        return $countries;
    }

    function getEventName($id) {
        $collection = $this->mongo_db->db->selectCollection('events');
        $name = $collection->findOne(array('_id' => new MongoId($id)), array('eventName'));
        return $name;
    }
}

?>